﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WpfStarterKit.Framework.ViewModel;
using System.Threading;
using WpfStarterKit.Framework.Navigation;
using System.Windows.Input;
using WpfStarterKit.Framework.Commands;

namespace WpfStarterKit.SampleApplication.Screens.LongRunningOperation.LongRunningPage
{
    public class LongRunningViewModel : UserInterfaceViewModel
    {
        public LongRunningViewModel()
        {
            HomeCommand = new NavigationCommand(NavigationActions.Start);
            LongRunningCommand = new RelayCommand(LongRunningCode);
        }

        public virtual ICommand HomeCommand { get; set; }

        [LongRunningOperation(Message = "Loading long running page")]
        public override void Initialize()
        {
            base.Initialize();
            for(int i = 0; i < 3; i++)
            {
                Thread.Sleep(new TimeSpan(0, 0, 1));
            }
        }

        public virtual ICommand LongRunningCommand { get; set; }

        [LongRunningOperation(Message = "This should take some time")]
        void LongRunningCode(object parameter)
        {
            for (int i = 0; i < 6; i++)
            {
                Thread.Sleep(new TimeSpan(0, 0, 1));
            }
        }
    }
}
